/* Image Config Modal - 图片配置弹窗样式 */

.image-config-modal {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-config-modal.show {
  opacity: 1;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: #efe4d4;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 420px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  border: 1px solid #d8c9ba;
  pointer-events: auto;
}

/* 弹窗头部 */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #d8c9ba;
  background: #c7d5e8;
  min-height: 36px;
}

.image-config-modal .modal-title {
  font-size: 14px;
  font-weight: normal;
  margin: 0;
  color: #000000 !important;
  text-shadow: none;
  box-shadow: none;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 16px;
  color: #6a6a6a;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.modal-close-btn:hover {
  background: #a8bedf;
  color: #333;
}

/* 标签页 */
.modal-tabs {
  display: flex;
  background: #efe4d4;
  border-bottom: 1px solid #c7d5e8;
}

.tab-btn {
  flex: 1;
  padding: 6px 8px;
  border: none;
  background: none;
  font-size: 12px;
  color: #5a5a5a;
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
}

.image-config-modal .tab-btn.active {
  color: #2c3e50 !important;
  border-bottom-color: #a8bedf !important;
  background: #a8bedf !important;
  font-weight: 500;
  box-shadow: none !important;
}

.tab-btn:hover:not(.active) {
  background: #c7d5e8;
  color: #333;
}

/* 弹窗主体 */
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  background: #ffffff;
}

.config-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* 上传区域 */
.upload-section {
  margin-bottom: 6px;
}

.upload-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

.upload-btn {
  background: #a8bedf;
  color: #2c3e50;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: background-color 0.2s;
  white-space: nowrap;
  font-weight: 500;
}

.upload-btn:hover {
  background: #c7d5e8;
  color: #1a252f;
}

.url-input {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid #d8c9ba;
  border-radius: 6px;
  font-size: 11px;
  background: #ffffff;
  color: #333;
}

.url-input:focus {
  outline: none;
  border-color: #a8bedf;
  box-shadow: 0 0 0 2px rgba(168, 190, 223, 0.2);
}

/* 预览区域 */
.preview-section {
  margin-bottom: 6px;
}

.preview-container {
  position: relative;
  margin: 0 auto;
  border: 2px solid #d8c9ba;
  border-radius: 8px;
  overflow: hidden;
  background: transparent; /* 修复：使用透明背景，避免缩放时显示蓝色背景 */
  cursor: grab;
}

.preview-container:active {
  cursor: grabbing;
}

/* 头像预览 - 圆形 */
.avatar-preview {
  width: 100px;
  height: 100px;
  border-radius: 50%;
}

/* 背景预览 - 竖向长方形，匹配消息列表比例 */
.background-preview {
  width: 90px;
  height: 120px;
  border-radius: 8px;
}

.preview-image {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center center;
  transition: transform 0.1s ease;
}

.drag-hint {
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: var(--text-color-secondary, #666);
  background: rgba(255, 255, 255, 0.8);
  padding: 1px 3px;
  border-radius: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.preview-container:hover .drag-hint {
  opacity: 1;
}

/* 控制区域 */
.controls-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}

.control-row label {
  min-width: 30px;
  color: #4a4a4a;
  font-weight: 500;
}

.control-slider {
  flex: 1;
  height: 16px;
  -webkit-appearance: none;
  appearance: none;
  background: #d8c9ba;
  border-radius: 8px;
  outline: none;
}

.control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: #a8bedf;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid #2c3e50;
}

.control-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: #a8bedf;
  border-radius: 50%;
  cursor: pointer;
  border: 1px solid #2c3e50;
}

.control-value {
  min-width: 32px;
  text-align: right;
  color: #6a6a6a;
  font-size: 10px;
}

/* 弹窗底部 */
.modal-footer {
  padding: 8px 12px;
  border-top: 1px solid #d8c9ba;
  background: #c7d5e8;
}

.save-btn {
  width: 100%;
  background: #a8bedf;
  color: #2c3e50;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.save-btn:hover {
  background: #d8c9ba;
  color: #1a252f;
}

.save-btn:disabled {
  background: #e0e0e0;
  color: #999;
  cursor: not-allowed;
}

/* 响应式设计 */
@media (max-width: 480px) {
  .modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .upload-controls {
    flex-direction: column;
    gap: 3px;
  }

  .url-input {
    width: 100%;
  }

  .avatar-preview {
    width: 85px;
    height: 85px;
  }

  .background-preview {
    width: 75px;
    height: 100px;
  }

  .control-row {
    font-size: 10px;
  }

  .control-row label {
    min-width: 28px;
  }
}

@media (max-width: 360px) {
  .modal-content {
    width: 98%;
    max-height: 95vh;
  }

  .modal-header {
    padding: 6px 10px;
    min-height: 32px;
  }

  .modal-title {
    font-size: 13px;
  }

  .tab-btn {
    padding: 5px 6px;
    font-size: 11px;
  }

  .modal-body {
    padding: 6px;
  }

  .config-section {
    gap: 4px;
  }

  .avatar-preview {
    width: 75px;
    height: 75px;
  }

  .background-preview {
    width: 65px;
    height: 87px;
  }

  .upload-btn {
    padding: 3px 6px;
    font-size: 10px;
  }

  .url-input {
    padding: 3px 5px;
    font-size: 10px;
  }

  .control-row {
    font-size: 9px;
  }

  .control-value {
    font-size: 9px;
    min-width: 28px;
  }

  .save-btn {
    padding: 5px 10px;
    font-size: 11px;
  }

  .drag-hint {
    font-size: 7px;
    padding: 0px 2px;
  }
}

/* 暗色主题适配 */
@media (prefers-color-scheme: dark) {
  .modal-content {
    background: var(--bg-color-dark, #1c1c1e);
    color: var(--text-color-dark, #ffffff);
  }

  .modal-header,
  .modal-tabs,
  .modal-footer {
    background: var(--header-bg-dark, #2c2c2e);
    border-color: var(--border-color-dark, #3a3a3c);
  }

  .tab-btn.active {
    background: var(--bg-color-dark, #1c1c1e);
  }

  .url-input {
    background: var(--input-bg-dark, #2c2c2e);
    border-color: var(--border-color-dark, #3a3a3c);
    color: var(--text-color-dark, #ffffff);
  }

  .preview-container {
    border-color: var(--border-color-dark, #3a3a3c);
    background: transparent; /* 修复：深色模式下也使用透明背景 */
  }

  .control-slider {
    background: var(--slider-bg-dark, #3a3a3c);
  }
}

/* 好友图片配置弹窗专用样式 */
.friend-image-config-modal {
  /* 继承所有基础样式，只需要特殊定制的部分 */
  position: absolute !important; /* 确保在手机容器内正确定位 */
}

.friend-image-config-modal .modal-title {
  color: #000000 !important;
  font-weight: 500;
}

/* 好友弹窗的头像预览 - 简化方案，使用overflow裁剪 */
.friend-image-config-modal .avatar-preview {
  position: relative;
  border-radius: 50% !important;
  overflow: hidden !important; /* 使用简单的overflow裁剪 */
  border: 2px solid #d8c9ba !important;
}

.friend-image-config-modal .avatar-preview .preview-image {
  border-radius: 0 !important;
  /* 移除可能导致问题的clip-path和mask */
}

/* 好友弹窗的背景预览 - 竖向长方形 */
.friend-image-config-modal .background-preview .preview-image {
  border-radius: 8px;
  aspect-ratio: 3/4; /* 竖向长方形比例 */
}

/* 好友弹窗的响应式设计 */
@media (max-width: 480px) {
  .friend-image-config-modal .modal-content {
    width: 95%;
    max-height: 90vh;
  }

  .friend-image-config-modal .avatar-preview {
    width: 85px;
    height: 85px;
  }

  .friend-image-config-modal .background-preview {
    width: 75px;
    height: 100px;
  }
}

@media (max-width: 360px) {
  .friend-image-config-modal .modal-content {
    width: 98%;
    max-height: 95vh;
  }

  .friend-image-config-modal .avatar-preview {
    width: 75px;
    height: 75px;
  }

  .friend-image-config-modal .background-preview {
    width: 65px;
    height: 87px;
  }
}
